package com.example.demo.vo

import com.example.demo.dao.TDeptDao
import com.example.demo.dao.TDoctorOrderDao
import com.example.demo.dbmodels.TDoctorOrder
import me.liuwj.ktorm.dsl.QueryRowSet
import java.time.LocalDateTime

class DoctorOrderVo {

    /**
     *  主键
     **/
    var id: Int? = null
    /**
     *  医嘱执行编码
     **/
    var order_no: String? = null
    /**
     *  病人代码
     **/
    var patient_code: String? = null
    /**
     *  住院号
     **/
    var patient_cure_no: String? = null
    /**
     *  医嘱组合
     **/
    var group_code: String? = null
    /**
     *  药品编码
     **/
    var drug_code: String? = null
    /**
     *  医嘱名称
     **/
    var order_name: String? = null
    /**
     *  药物规格
     **/
    var standards: String? = null
    /**
     *  给药方式
     **/
    var drug_way: String? = null
    /**
     *  执行频率: 类似:2次/天或BID等
     **/
    var frequency: String? = null
    /**
     *  一次剂量
     **/
    var c_qty: Float?= null
    /**
     *  一次剂量单位
     **/
    var c_qty_unit: String? = null
    /**
     *  一次数量
     **/
    var n_qty: Float?= null
    /**
     *  一次数量单位
     **/
    var n_qty_unit: String? = null
    /**
     *  计划用药日期
     **/
    var use_date: LocalDateTime?= null
    /**
     *  开医嘱医生编码
     **/
    var doctor_code: String? = null
    /**
     *  是否皮试
     **/
    var skin_test: Int?= null
    /**
     *  是否婴儿
     **/
    var is_baby: Boolean?= null
    /**
     *  医嘱说明
     **/
    var remark: String? = null
    /**
     *  是否自带药
     **/
    var own_drug: Int?= null
    /**
     *  是否已经取消
     **/
    var is_cancel: Boolean?= null
    /**
     *  是否已执行
     **/
    var is_exec: Boolean?= null
    /**
     *  执行人ID
     **/
    var exec_user_id: Int?= null
    /**
     *  执行时间
     **/
    var exec_time: LocalDateTime?= null
    /**
     *  医嘱类型: 0=临嘱, 1=长嘱
     **/
    var order_type: Int?= null
    /**
     *  打印类型
     **/
    var print_type: String? = null
    /**
     *  滴速
     **/
    var drip_speed: Int?= null
    /**
     *  滴速单位:  0: 滴/分(默认); 1:毫升/分
     **/
    var drip_speed_unit: Int?= null
    /**
     *  若1天内有编号相同,执行日期相同的药组,必须传此字段区分
     **/
    var dupli_drup_flag: Boolean?= null
    /**
     *  更新人ID
     **/
    var update_by: Int?=  null
    /**
     *  更新时间
     **/
    var update_time: LocalDateTime?= null
    /**
     *  删除标记
     **/
    var is_del: Boolean?= null

    fun getDoctorOrderVo(table: TDoctorOrder?):DoctorOrderVo?{
        table?.let {
            val data = DoctorOrderVo()
            data.c_qty= it.c_qty
            data.c_qty_unit = it.c_qty_unit
            data.doctor_code = it.doctor_code
            data.drip_speed = it.drip_speed
            data.drip_speed_unit = it.drip_speed_unit
            data.drug_code = it.drug_code
            data.drug_way = it.drug_way
            data.dupli_drup_flag = it.dupli_drup_flag
            data.exec_time = it.exec_time
            data.exec_user_id = it.exec_user_id
            data.frequency = it.frequency
            data.group_code = it.group_code
            data.id = it.id
            data.is_baby = it.is_baby
            data.is_cancel = it.is_cancel
            data.is_del = it.is_del
            data.is_exec = it.is_exec
            data.n_qty = it.n_qty
            data.n_qty_unit = it.n_qty_unit
            data.order_name = it.order_name
            data.order_no = it.order_no
            data.order_type = it.order_type
            data.own_drug = it.own_drug
            data.patient_code = it.patient_code
            data.patient_cure_no = it.patient_cure_no
            data.print_type = it.print_type
            data.remark = it.remark
            data.skin_test = it.skin_test
            data.standards = it.standards
            data.update_by= it.update_by
            data.update_time = it.update_time
            data.use_date = it.use_date
            return  data
        }
        return null
    }


    fun getDoctorOrderVoList(table:  List<TDoctorOrder> ?): List<DoctorOrderVo>?{
        table?.let {
            val doctorOrderVoList = mutableListOf<DoctorOrderVo>()
            table.forEach {
                val data = DoctorOrderVo()
                data.c_qty= it.c_qty
                data.c_qty_unit = it.c_qty_unit
                data.doctor_code = it.doctor_code
                data.drip_speed = it.drip_speed
                data.drip_speed_unit = it.drip_speed_unit
                data.drug_code = it.drug_code
                data.drug_way = it.drug_way
                data.dupli_drup_flag = it.dupli_drup_flag
                data.exec_time = it.exec_time
                data.exec_user_id = it.exec_user_id
                data.frequency = it.frequency
                data.group_code = it.group_code
                data.id = it.id
                data.is_baby = it.is_baby
                data.is_cancel = it.is_cancel
                data.is_del = it.is_del
                data.is_exec = it.is_exec
                data.n_qty = it.n_qty
                data.n_qty_unit = it.n_qty_unit
                data.order_name = it.order_name
                data.order_no = it.order_no
                data.order_type = it.order_type
                data.own_drug = it.own_drug
                data.patient_code = it.patient_code
                data.patient_cure_no = it.patient_cure_no
                data.print_type = it.print_type
                data.remark = it.remark
                data.skin_test = it.skin_test
                data.standards = it.standards
                data.update_by= it.update_by
                data.update_time = it.update_time
                data.use_date = it.use_date
                doctorOrderVoList.add(data)
            }
            return  doctorOrderVoList
        }
        return null
    }


    fun getDoctorOrderVo(queue: QueryRowSet?):DoctorOrderVo?{
        queue?.let {
            val data = DoctorOrderVo()
            data.c_qty= it[TDoctorOrderDao.c_qty]
            data.c_qty_unit =  it[TDoctorOrderDao.c_qty_unit]
            data.doctor_code = it[TDoctorOrderDao.doctor_code]
            data.drip_speed = it[TDoctorOrderDao.drip_speed]
            data.drip_speed_unit = it[TDoctorOrderDao.drip_speed_unit]
            data.drug_code = it[TDoctorOrderDao.drug_code]
            data.drug_way = it[TDoctorOrderDao.drug_way]
            data.dupli_drup_flag =  it[TDoctorOrderDao.dupli_drup_flag]
            data.exec_time = it[TDoctorOrderDao.exec_time]
            data.exec_user_id =  it[TDoctorOrderDao.exec_user_id]
            data.frequency = it[TDoctorOrderDao.frequency]
            data.group_code = it[TDoctorOrderDao.group_code]
            data.id =  it[TDoctorOrderDao.id]
            data.is_baby = it[TDoctorOrderDao.is_baby]
            data.is_cancel = it[TDoctorOrderDao.is_cancel]
            data.is_del =  it[TDoctorOrderDao.is_del]
            data.is_exec = it[TDoctorOrderDao.is_exec]
            data.n_qty =  it[TDoctorOrderDao.n_qty]
            data.n_qty_unit =  it[TDoctorOrderDao.n_qty_unit]
            data.order_name = it[TDoctorOrderDao.order_name]
            data.order_no =  it[TDoctorOrderDao.order_no]
            data.order_type =  it[TDoctorOrderDao.order_type]
            data.own_drug = it[TDoctorOrderDao.own_drug]
            data.patient_code =  it[TDoctorOrderDao.patient_code]
            data.patient_cure_no =  it[TDoctorOrderDao.patient_cure_no]
            data.print_type =  it[TDoctorOrderDao.print_type]
            data.remark = it[TDoctorOrderDao.remark]
            data.skin_test = it[TDoctorOrderDao.skin_test]
            data.standards = it[TDoctorOrderDao.standards]
            data.update_by=  it[TDoctorOrderDao.update_by]
            data.update_time = it[TDoctorOrderDao.update_time]
            data.use_date = it[TDoctorOrderDao.use_date]
            return  data
        }
        return null
    }

}